package com.LeeCode;

/**
 * 最佳观光组合
 */

public class Code1014 {
    public static void main(String[] args) {
        int[] values = {8, 1, 5, 2, 6};
        System.out.println(new Code1014().maxScoreSightseeingPair(values));
    }

    public int maxScoreSightseeingPair(int[] values) {
        int prevMax = values[0], ans = 0;
        for (int i = 1; i < values.length; i++) {
            ans = Math.max(ans, prevMax + values[i] - i);
            prevMax = Math.max(prevMax, values[i] + i);
        }
        return ans;
    }
}
